import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { EReward } from "../../../../../Message/Public/EReward";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
type int = number;
//class DailyAwardItem
    
    export  class DailyAwardItem /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int=-1)
        {
            
            this._type = arg1;
            this._max = arg2;
            mouseEnabled = false;
            mouseChildren = false;
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._fontImg = new Object /* flash.display.Bitmap */();
            addChild(this._fontImg);
            this._itemBox = new GBox();
            this._itemBox.horizontalGap = 4;
            this._itemBox.direction = GBoxDirection.HORIZONTAL;
            this._itemBox.x = 27;
            this._itemBox.y = 2;
            addChild(this._itemBox);
            return;
        }

        protected onDailyResLoadedHandler(): void
        {
            var loc2=null;
            var loc3=this._type;
            switch (loc3) 
            {
                case EReward._ERewardExperience:
                {
                    this._fontImg.bitmapData = GlobalClass.getBitmapData(ImagesConst.expText);
                    break;
                }
                case EReward._ERewardItem:
                {
                    this._fontImg.bitmapData = GlobalClass.getBitmapData(ImagesConst.itemText);
                    break;
                }
                case EReward._ERewardCoin:
                {
                    this._fontImg.bitmapData = GlobalClass.getBitmapData(ImagesConst.copperText);
                    break;
                }
            }
            if (!contains(this._fontImg)) 
            {
                addChild(this._fontImg);
            }
            var loc1=0;
            while (loc1 < this._max && this._itemBox.numChildren < this._max) 
            {
                if (loc1 < this._value) 
                {
                    loc2 = GlobalClass.getBitmap(ImagesConst.DailyStar);
                }
                else 
                {
                    loc2 = GlobalClass.getBitmap(ImagesConst.DailyStar1);
                }
                this._itemBox.addChild(loc2);
                ++loc1;
            }
            this._itemBox.invalidate();
            return;
        }

        public updateData(arg1: int, arg2: int, arg3: int=5): void
        {
            this.clear();
            this._type = arg2;
            this._max = arg3;
            this._value = arg1;
            LoaderHelp.addResCallBack(ResFileConst.daily, this.onDailyResLoadedHandler);
            return;
        }

        public dispose(): void
        {
            this.clear();
            if (this._max != -1) 
            {
                this.updateData(0, this._type, this._max);
            }
            return;
        }

        public clear(): void
        {
            while (this._itemBox.numChildren > 0) 
            {
                this._itemBox.removeChildAt(0);
            }
            if (this._fontImg && contains(this._fontImg)) 
            {
                removeChild(this._fontImg);
            }
            return;
        }

        public /* override */ get height(): number
        {
            return 15;
        }

        protected /* var */_fontImg: Object /* flash.display.Bitmap */;

        protected /* var */_itemBox: GBox;

        protected /* var */_max: int;

        protected /* var */_type: int;

        protected /* var */_value: int;
    }
